import Constants

/**
 * System Role
 */
class Role {
    String roleName
    String description

	static mapping = {
		table Constants.DOMAIN_TABLE_PREFIX + '_ROLE'
		users joinTable: Constants.DOMAIN_TABLE_PREFIX + '_USER_ROLE'
		privileges joinTable: Constants.DOMAIN_TABLE_PREFIX + '_ROLE_PRIV'
	}

	static belongsTo = User
	static hasMany=[privileges: Privilege, users: User]

	static constraints = {
		roleName(unique:true, blank:false, maxSize:16)
		description(maxSize:256)
	}

	String toString(){
		"${this.roleName}"
	}
}
